Skip to content

Add test coverage for overview_resampling min/max/median modes#1639

Merged
brendancol merged 2 commits into
mainfrom
deep-sweep-test-coverage-geotiff-2026-05-11-1778543786
May 12, 2026
Merged

Add test coverage for overview_resampling min/max/median modes#1639
brendancol merged 2 commits into
mainfrom
deep-sweep-test-coverage-geotiff-2026-05-11-1778543786

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

The to_geotiff and write_geotiff_gpu overview_resampling parameter accepts six documented modes (mean, nearest, mode, cubic, min, max, median). The last three had no tests on either the CPU block reducer (_block_reduce_2d) or the GPU block reducer (_block_reduce_2d_gpu). A regression in any of those branches would ship undetected.

This PR closes a Cat 4 HIGH parameter-coverage gap surfaced by pass 6 of the test-coverage sweep on the geotiff module.

What is added

26 new tests in xrspatial/geotiff/tests/test_overview_resampling_min_max_median_2026_05_11.py:

  • CPU and GPU block-reducer unit tests on finite input (closed-form 2x2 reductions).
  • CPU and GPU block-reducer unit tests on partial-NaN input verifying the nan-aware reductions skip NaN cells.
  • End-to-end COG round-trips for to_geotiff(cog=True) and write_geotiff_gpu(cog=True) for each of the three modes.
  • CPU/GPU parity check for to_geotiff(gpu=True) overview output.
  • CPU nodata-sentinel regression (issue COG overview generation poisoned by nodata sentinel #1613 path, extended to the min/max/median branches that COG overview generation poisoned by nodata sentinel #1613 did not cover).
  • Error-path tests: ValueError on an unknown method name for both backends.

No source changes. All 26 tests pass locally on a GPU-enabled host.

Test plan

  • pytest xrspatial/geotiff/tests/test_overview_resampling_min_max_median_2026_05_11.py -v -> 26 passed
  • CI green on the existing geotiff test matrix

The to_geotiff and write_geotiff_gpu overview_resampling parameter
accepts six modes (mean, nearest, mode, cubic, min, max, median) but the
last three had no test coverage on either the CPU block reducer
(_block_reduce_2d) or the GPU block reducer (_block_reduce_2d_gpu). A
regression in any of those branches would ship undetected.

This commit closes a Cat 4 HIGH parameter-coverage gap with 26 new
tests:

* CPU and GPU unit tests for the block reducer on finite input.
* CPU and GPU unit tests for partial-NaN input verifying the
  nan-aware reductions skip NaN cells.
* End-to-end COG writes for to_geotiff(cog=True) and
  write_geotiff_gpu(cog=True) for each of the three modes.
* CPU/GPU parity check for to_geotiff(gpu=True) overview output.
* CPU nodata-sentinel regression (issue 1613 path, here extended to
  the min/max/median branches that 1613 did not test).
* Error path: ValueError on an unknown method name for both
  backends.

All 26 tests pass on a GPU-enabled host.

Pass 6 of the test-coverage sweep on the geotiff module. State CSV
notes column updated.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 12, 2026
@brendancol brendancol requested a review from Copilot May 12, 2026 00:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new test coverage for overview_resampling modes min, max, and median across CPU and GPU GeoTIFF COG overview generation, focusing on both unit-level block reducers and end-to-end writer/reader round-trips.

Changes:

  • Add CPU/GPU unit tests for _block_reduce_2d / _block_reduce_2d_gpu for min/max/median on finite and partial-NaN inputs.
  • Add end-to-end COG overview round-trip tests for to_geotiff(..., cog=True) and write_geotiff_gpu(..., cog=True) for those modes, plus CPU/GPU parity coverage.
  • Update the internal .claude sweep state tracking entry for the geotiff module.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
xrspatial/geotiff/tests/test_overview_resampling_min_max_median_2026_05_11.py New tests covering min/max/median overview resampling for CPU and GPU paths, including unit + end-to-end coverage.
.claude/sweep-test-coverage-state.csv Updates test-coverage sweep tracking notes for the geotiff module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


The CPU writer (``xrspatial.geotiff._writer._block_reduce_2d``) and the
GPU writer (``xrspatial.geotiff._gpu_decode._block_reduce_2d_gpu``) both
implement six resampling reductions for COG overview generation:
Comment on lines +13 to +15
* ``min`` -- NO coverage prior to this file.
* ``max`` -- NO coverage prior to this file.
* ``median`` -- NO coverage prior to this file.
Comment thread .claude/sweep-test-coverage-state.csv Outdated
@@ -1,3 +1,3 @@
module,last_inspected,issue,severity_max,categories_found,notes
geotiff,2026-05-11,,HIGH,2;3,"Pass 5 (2026-05-11): added test_degenerate_shapes_backends_2026_05_11.py covering Cat 3 HIGH geometric gaps (1x1 / 1xN / Nx1 reads on dask+numpy, GPU, dask+cupy backends; 1x1 / 1xN / Nx1 writes through write_geotiff_gpu) and Cat 2 MEDIUM NaN/Inf gaps (all-NaN read on GPU + dask+cupy, Inf / -Inf reads on all non-eager backends, NaN sentinel mask on dask read path including sentinel block split across chunk boundary). 23 tests, all passing on GPU host. Prior passes still hold: pass 4 (r4) closed read_geotiff_gpu/dask name= + max_pixels= kwargs (Cat 4), pass 3 (r3) closed read_vrt GPU/dask+GPU backend dispatch (Cat 1) and dtype/name kwargs (Cat 4)."
geotiff,2026-05-11,,HIGH,2;3;4,"Pass 6 (2026-05-11): added test_overview_resampling_min_max_median_2026_05_11.py covering Cat 4 HIGH parameter-coverage gap on overview_resampling=min/max/median. Both CPU (_block_reduce_2d) and GPU (_block_reduce_2d_gpu) reductions had branches with zero test coverage; an unnoticed regression in any of the three modes would ship undetected. 26 tests, all passing on GPU host: block-reducer unit tests (finite + partial-NaN), end-to-end COG writes for both to_geotiff and write_geotiff_gpu, CPU/GPU parity for to_geotiff(gpu=True), CPU nodata-sentinel regression check, and ValueError error-path tests for unknown method names on both backends. Pass 5 (2026-05-11): added test_degenerate_shapes_backends_2026_05_11.py covering Cat 3 HIGH geometric gaps (1x1 / 1xN / Nx1 reads on dask+numpy, GPU, dask+cupy backends; 1x1 / 1xN / Nx1 writes through write_geotiff_gpu) and Cat 2 MEDIUM NaN/Inf gaps (all-NaN read on GPU + dask+cupy, Inf / -Inf reads on all non-eager backends, NaN sentinel mask on dask read path including sentinel block split across chunk boundary). 23 tests, all passing on GPU host. Prior passes still hold: pass 4 (r4) closed read_geotiff_gpu/dask name= + max_pixels= kwargs (Cat 4), pass 3 (r3) closed read_vrt GPU/dask+GPU backend dispatch (Cat 1) and dtype/name kwargs (Cat 4)."
- Fix "six" -> "seven" reductions count (mean, nearest, min, max,
  median, mode, cubic).
- Reword module docstring: CPU end-to-end paths for min/max/median
  were already covered by test_cog_overview_nodata_1613; the gap
  this file closes is GPU end-to-end + direct CPU/GPU block-reducer
  branches.
- Mirror the clarification in the sweep-test-coverage state CSV row.
@brendancol brendancol merged commit 977968f into main May 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants